//
//  SystemTools.m
//  MobileVLCKitDemo
//
//  Created by 金色榜样研发组 on 2019/5/30.
//  Copyright © 2019 Golden Bangyang (beijing) Cul Ture Media Investment Co. All rights reserved.
//

#import "SystemTools.h"
#import <AVFoundation/AVFoundation.h>

@implementation SystemTools

#pragma mark ---- 获取视频的第一帧图片

+ (UIImage*)getVideoPreViewImage:(NSURL *)url
{
    AVURLAsset *asset = [AVURLAsset assetWithURL:url];
    NSLog(@"asset = %@",asset);
    AVAssetImageGenerator *assetGen = [[AVAssetImageGenerator alloc] initWithAsset:asset];
    assetGen.appliesPreferredTrackTransform = YES;
    CMTime time = CMTimeMakeWithSeconds(0.0, 600);
    NSError *error = nil;
    CMTime actualTime;
    CGImageRef image = [assetGen copyCGImageAtTime:time actualTime:&actualTime error:&error];
    UIImage *videoImage = [[UIImage alloc] initWithCGImage:image];
    CGImageRelease(image);
    return videoImage;
}



@end
